<?php
require('PHPMailer/class.phpmailer.php');


set_error_handler("my_warning_handler");

function my_warning_handler($errno, $errstr) {
	switch ($errno) {
		case E_WARNING:
			header("Location:interconsulta.php".URL_APPEND);
			exit(1);
			break;
		}
	return true;
}

function enviar_mail($to, $subject, $message) {
	$mail = new PHPMailer();

	$mail->IsSMTP();                    // set mailer to use SMTP
	$mail->Host = 'localhost';  // specify main and backup server
	$mail->SMTPAuth = false;   	    // turn on SMTP authentication

	$mail->From = 'info@sinapsis.org';
	$mail->FromName = 'Sinapsis';
	$mail->AddAddress($to);
	
	$mail->WordWrap = 50;                                 // set word wrap to 50 characters
	$mail->IsHTML(true);                                  // set email format to HTML

	$mail->Subject = $subject;
	$mail->Body    = $message;

	if(!$mail->Send()){
	system("logger -t sinapsis \"No se pudo enviar email: " . $mail->ErrorInfo . "\"");
	}
}
?>
